/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.ad.entity;

import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import com.jeesite.modules.ad.utils.excel.fieldtype.IndustryType;

/**
 * 广告主Entity
 * @author chenxm
 * @version 2019-04-16
 */
@Table(name="ad_vertiser", alias="a", columns={
		@Column(name="id", attrName="id", label="ID", isPK=true),
		@Column(name="account", attrName="account", label="账户名称"),
		@Column(name="industry_code", attrName="industryCode.industryCode", label="行业分类"),
		@Column(name="email", attrName="email", label="账户邮箱"),
		@Column(name="password", attrName="password", label="账户密码"),
		@Column(name="contact", attrName="contact", label="联系人"),
		@Column(name="mobile", attrName="mobile", label="联系电话"),
		@Column(name="company_name", attrName="companyName", label="公司名称", queryType=QueryType.LIKE),
		@Column(name="company_website", attrName="companyWebsite", label="公司官网"),
		@Column(name="user_code", attrName="userCode", label="关联用户"),
		@Column(name="agent_Id", attrName="agentId", label="代理商ID"),
		@Column(includeEntity=DataEntity.class),
	}, joinTable= {
		@JoinTable(type=Type.LEFT_JOIN, entity=AdIndustryType.class, alias="b", 
				on="b.industry_code = a.industry_code", attrName="industryCode",
				columns={@Column(includeEntity=AdIndustryType.class)}),
			
	}, orderBy="a.update_date DESC",extFromKeys="date_join",extColumnKeys="extColumn"
)
public class AdVertiser extends DataEntity<AdVertiser> {
	
	@Valid
	@ExcelFields({
		@ExcelField(title="账户名称", attrName="account", align=Align.CENTER, sort=10),
		@ExcelField(title="行业分类", attrName="industryCode", align = Align.CENTER, sort=20, fieldType=IndustryType.class),
		@ExcelField(title="账户邮箱", attrName="email", align=Align.CENTER, sort=30),
		@ExcelField(title="账户密码", attrName="password", align=Align.CENTER, sort=40),
		@ExcelField(title="联系人", attrName="contact", align=Align.LEFT, sort=50),
		@ExcelField(title="联系电话", attrName="mobile", align=Align.CENTER, sort=60),
		@ExcelField(title="公司名称", attrName="companyName", align=Align.CENTER, sort=70),
		@ExcelField(title="公司官网", attrName="companyWebsite", align=Align.CENTER, sort=80),
		@ExcelField(title = "创建时间", attrName = "createDate", align = Align.CENTER, sort = 170, dataFormat = "yyyy-MM-dd", type=ExcelField.Type.EXPORT), 
		@ExcelField(title = "修改时间", attrName = "updateDate", align = Align.CENTER, sort = 180, dataFormat = "yyyy-MM-dd", type=ExcelField.Type.EXPORT),
	})
	private static final long serialVersionUID = 1L;
	private String account;		// 账户名称
	private AdIndustryType industryCode;		// 行业分类
	private String email;		// 账户邮箱
	private String password;		// 账户密码
	private String contact;		// 联系人
	private String mobile;		// 联系电话
	private String companyName;		// 公司名称
	private String companyWebsite;		// 公司官网
	private String userCode;		// 关联用户
	private String agentId;		// 代理商ID
	private List<Ad> adList = ListUtils.newArrayList();		//广告计划

	public AdVertiser() {
		this(null);
	}

	public AdVertiser(String id){
		super(id);
	}
	
	public List<Ad> getAdList() {
		return adList;
	}

	public void setAdList(List<Ad> adList) {
		this.adList = adList;
	}

	@NotBlank(message="账户名称不能为空")
	@Length(min=0, max=200, message="账户名称长度不能超过 200 个字符")
	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	@NotNull(message="行业分类不能为空")
//	@NotBlank(message="行业分类不能为空")
//	@Length(min=0, max=100, message="行业分类长度不能超过 100 个字符")
	public AdIndustryType getIndustryCode() {
		return industryCode;
	}

	public void setIndustryCode(AdIndustryType industryCode) {
		this.industryCode = industryCode;
	}

	@NotBlank(message="账户邮箱不能为空")
	@Length(min=0, max=255, message="账户邮箱长度不能超过 255 个字符")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@NotBlank(message="账户密码不能为空")
	@Length(min=0, max=255, message="账户密码长度不能超过 255 个字符")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@Length(min=0, max=10, message="联系人长度不能超过 10 个字符")
	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}
	
	@Length(min=0, max=20, message="联系电话长度不能超过 20 个字符")
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	@Length(min=0, max=50, message="公司名称长度不能超过 50 个字符")
	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	
	@Length(min=0, max=255, message="公司官网长度不能超过 255 个字符")
	public String getCompanyWebsite() {
		return companyWebsite;
	}

	public void setCompanyWebsite(String companyWebsite) {
		this.companyWebsite = companyWebsite;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getAgentId() {
		return agentId;
	}

	public void setAgentId(String agentId) {
		this.agentId = agentId;
	}
}